package com.zhangxin.threadcoreknowledge.sixstates;

public class Demo01NewRunnableTerinated implements Runnable{
    public static void main(String[] args) {
        Thread thread1 = new Thread(new Demo01NewRunnableTerinated());
        // 打印NEW的状态
        System.out.println(thread1.getState()); // NEW
        thread1.start(); // 调用start之后就是Runnable状态
        System.out.println(thread1.getState());  // RUNNABLE
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(thread1.getState());  // RUNNABLE
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(thread1.getState()); // TERMINATED
    }

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println(i);
        }
    }
}
